#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
double n,m,L,V;
struct car{
    double d,v,a;
    int time;
    queue<int> bc;
}c[N];
struct jc{
	set<int> cc;
}s[N];
double p[N];
int times[N];
int cnt,ans;
bool choose[N];
bool mustchoose[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
		ans=0x3f3f3f3f;
		memset(c,0,sizeof c);
		memset(s,0,sizeof s);
        memset(times,0,sizeof times);
        memset(choose,false,sizeof choose);
        cnt=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i=1;i<=m;i++)cin>>p[i];
        for(int i=1;i<=n;i++){
            bool flag=false;
            for(int j=1;j<=m;j++){
                if(c[i].d>p[j])continue;
                else if(c[i].d==p[j]){
                    if(c[i].v>V){
                        times[j]++;
                        //c[i].bc.push(j);
                        //s[j].cc.insert(i);
                        flag=true;
                    }
                    continue;
                }
                else if(c[i].v*c[i].v+2*c[i].a*(p[j]-c[i].d)<0)break;
                else if((double)sqrt(c[i].v*c[i].v+2*c[i].a*(p[j]-c[i].d))>(double)V){
                    flag=true;
                    times[j]++;
                    //c[i].bc.push(j);
                    //s[j].cc.insert(i);
                }
            }
            if(flag){
				cnt++;
			}
        }
        cout<<cnt<<" ";
        cout<<n-cnt+1<<endl;
		
    }
	
    return 0;
}
